﻿using System;
using System.Collections.Generic;
using IQToolkit;
using IQToolkit.Data;
using Infrastucture.Factories;
using TimeSplicerModule.DataModels;
using TimeSplicerModule.DomainModels;

namespace TimeSplicerModule.Factories
{
    public interface ITeamFactory : Infrastucture.Factories.IFactory<TeamDataModel, TeamModel>
    { }

    public class TeamFactory : Factory<TeamDataModel, TeamModel>, ITeamFactory
    {
        public TeamFactory(DbEntityProvider provider, IEntityTable<TeamDataModel> db)
            : base(provider, db)
        {

        }

        public override TeamModel CreateNew()
        {
            var model = base.CreateNew();
            model.Teams = this.GetList();

            return model;
        }

        public override List<TeamModel> GetList()
        {
            var list = base.GetList();

            foreach (var l in list)
                l.Teams = list;

            return list;
        }
    }
}
